﻿@model EQueue.AdminWeb.Models.BrokerTopicQueueListViewModel
@{
    ViewBag.Title = "队列信息";
    Layout = "~/Views/Shared/_BrokerLayout.cshtml";
}
<style>
    .header-form {
        display: inline-block;
        float: left;
    }
    .next-form {
        margin-left: 15px;
    }
</style>
<div>
    @using (Html.BeginForm("QueueInfoList", "Broker", new { clusterName = ViewBag.ClusterName, brokerName = ViewBag.BrokerName }, FormMethod.Post, new { @class = "form-inline header-form", role = "form" }))
    {
        <div class="form-group">
            <label class="sr-only" for="Topic"></label>
            @Html.TextBoxFor(m => m.Topic, new { @class = "form-control", placeholder = "Topic" })
        </div>
        <button type="submit" class="btn btn-default">查询</button>
    }
    @using (Html.BeginForm("CreateTopic", "Broker", new { clusterName = ViewBag.ClusterName, brokerName = ViewBag.BrokerName }, FormMethod.Post, new { @class = "form-inline header-form next-form", role = "form" }))
    {
        <div class="form-group">
            <label class="sr-only" for="topic"></label>
            <input id="topic" name="topic" type="text" class="form-control" placeholder="Topic" />
        </div>
        <div class="form-group">
            <label class="sr-only" for="initialQueueCount"></label>
            <input id="initialQueueCount" name="initialQueueCount" type="text" class="form-control" placeholder="InitialQueueCount" />
        </div>
        <button type="submit" class="btn btn-default">创建Topic</button>
    }
    @using (Html.BeginForm("DeleteTopic", "Broker", new { clusterName = ViewBag.ClusterName, brokerName = ViewBag.BrokerName }, FormMethod.Post, new { @class = "form-inline header-form next-form", role = "form" }))
    {
        <div class="form-group">
            <label class="sr-only" for="topic"></label>
            <input id="topic" name="topic" type="text" class="form-control" placeholder="Topic" />
        </div>
        <button type="submit" class="btn btn-default">删除Topic</button>
    }
    <table class="table table-striped">
        <thead>
            <tr>
                <th width="15%" class="vertical-center">
                    Topic
                </th>
                <th width="10%" class="text-center vertical-center">
                    QueueId
                </th>
                <th width="10%" class="text-center vertical-center">
                    CurrentOffset
                </th>
                <th width="10%" class="text-center vertical-center">
                    MinOffset
                </th>
                <th width="10%" class="text-center vertical-center">
                    消费进度
                </th>
                <th width="10%" class="text-center vertical-center">
                    堆积数
                </th>
                <th width="10%" class="text-center vertical-center">
                    A_S
                </th>
                <th width="10%" class="text-center vertical-center">
                    A_C
                </th>
                <th width="10%" class="text-center vertical-center">
                    发送TPS
                </th>
                <th width="5%" class="vertical-center">
                    操作
                </th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model.TopicQueueInfoList)
            {
                <tr>
                    <td class="vertical-center">
                        @item.Topic
                    </td>
                    <td class="text-center vertical-center">
                        @item.QueueId
                    </td>
                    <td class="text-center vertical-center">
                        @item.QueueCurrentOffset
                    </td>
                    <td class="text-center vertical-center">
                        @item.QueueMinOffset
                    </td>
                    <td class="text-center vertical-center">
                        @item.QueueMinConsumedOffset
                    </td>
                    <td class="text-center vertical-center">
                        @item.QueueNotConsumeCount
                    </td>
                    <td class="text-center vertical-center">
                        @item.ProducerVisible
                    </td>
                    <td class="text-center vertical-center">
                        @item.ConsumerVisible
                    </td>
                    <td class="text-center vertical-center">
                        @item.SendThroughput
                    </td>
                    <td class="vertical-center">
                        <div class="dropdown">
                            <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">
                                操作
                                <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu">
                                <li>
                                    @Html.ActionLink("新增队列", "AddQueue", new { clusterName = ViewBag.ClusterName, brokerName = ViewBag.BrokerName, topic = item.Topic })
                                </li>
                                <li>
                                    @if (item.ProducerVisible)
                                    {
                                        @Html.ActionLink("禁止发送", "SetQueueProducerVisible", new { clusterName = ViewBag.ClusterName, brokerName = ViewBag.BrokerName, topic = item.Topic, queueId = item.QueueId, visible = !item.ProducerVisible })
                                    }
                                    else
                                    {
                                        @Html.ActionLink("允许发送", "SetQueueProducerVisible", new { clusterName = ViewBag.ClusterName, brokerName = ViewBag.BrokerName, topic = item.Topic, queueId = item.QueueId, visible = !item.ProducerVisible })
                                    }
                                </li>
                                <li>
                                    @if (item.ConsumerVisible)
                                    {
                                        @Html.ActionLink("禁止消费", "SetQueueConsumerVisible", new { clusterName = ViewBag.ClusterName, brokerName = ViewBag.BrokerName, topic = item.Topic, queueId = item.QueueId, visible = !item.ConsumerVisible })
                                    }
                                    else
                                    {
                                        @Html.ActionLink("允许消费", "SetQueueConsumerVisible", new { clusterName = ViewBag.ClusterName, brokerName = ViewBag.BrokerName, topic = item.Topic, queueId = item.QueueId, visible = !item.ConsumerVisible })
                                    }
                                </li>
                                <li>@Html.ActionLink("删除队列", "DeleteQueue", new { clusterName = ViewBag.ClusterName, brokerName = ViewBag.BrokerName, topic = item.Topic, queueId = item.QueueId })</li>
                            </ul>
                        </div>
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>

